package router

import (
	"chat/api"

	"github.com/gin-gonic/gin"
)

func NewRouter() *gin.Engine {
	r := gin.Default()
	/*
		Recovery中间件:
		Logger日志
		**/
	r.Use(gin.Recovery(), gin.Logger())
	v1 := r.Group("/")
	{
		// 测试接口
		v1.GET(
			"ping",
			func(c *gin.Context) { c.JSON(200, "success") })
		// 用户注册接口
		v1.POST(
			"user/register",
			api.UserRegister,
		)
	}
	return r
}
